<?php

//-------------------------------------------------------------------------------------------------------
    require_once($config['app_dir'] . '/includes/object.class.php');
    require_once($config['app_dir'] . '/includes/template.class.php');
    require_once($config['app_dir'] . '/includes/mailer.class.php');
    //---------------------------------------------------------------------------------------------------
    class objContactsDlg  extends objObject implements iErrorHandler{
            protected $_status = 0;//0-empty 1 -get parameters
            protected $_error_str = array('',
                                          'Mailer error ');

        protected function _Perform() {
           //global $config;
            $this->_status = 0;
            if( 1==$_POST['__send'] ) {
                $Mailer = new objMailer();
                $Mailer->Subject='IntelliForex - From Site';
                $Mailer->FromName = "";
                $Mailer->From = $_POST['email'];
                $Mailer->Body = $_POST['body'] . "<br><br>E-mail: " . $_POST['email'];
                $Mailer->isHTML(true);

                $Mailer->AddAddress('support@intelli4x.com');
                //$Mailer->AddAddress('bohdan.sytch@gmail.com');
                if( !$Mailer->Send() ) {
                    $this->_error_no = 1;
                    $this->_error_str[$this->_error_no] .= $Mailer->ErrorInfo;
                    return false;
                } else $this->_status = 1;
            }
            return true;
        } //_Perform


        protected function _PerformFlash() {
           //global $config;
            $this->_status = 0;
            if( 1==$_POST['__send'] ) {
                $Mailer = new objMailer();
                $Mailer->Subject='IntelliForex - Flash Feddback';
                $Mailer->FromName = "";
                $Mailer->From = $_POST['email'];
                $Mailer->Body = $_POST['body'] . "<br><br>E-mail: " . $_POST['email'];
                $Mailer->isHTML(true);

                $Mailer->AddAddress('support@intelli4x.com');
                //$Mailer->AddAddress('bohdan.sytch@gmail.com');
                if( !$Mailer->Send() ) {
                    $this->_error_no = 1;
                    $this->_error_str[$this->_error_no] .= $Mailer->ErrorInfo;
                    return false;
                } else $this->_status = 1;
            }
            return true;
        } //_Perform

        public function Render() {
            if( !$this->_Perform() ) return false;
            $text = '';
            $Form = new objTemplate();
            $text .= $Form->Fetch('_form_contacts.tpl');
            if( !$this->_error_no && $this->_status) {
                //$text .= '<b>Thanks for contacting us.</b> Your message has been delivered.';
                $BodyContent = new objTemplate();
                $text .= $BodyContent->Fetch('users/_contacts.tpl');
            }
            return $text;
        } //Render

        public function FlashFeedback() {
            if( !$this->_PerformFlash() ) return false;
            $text = '';
            $Form = new objTemplate();
            $text .= $Form->Fetch('_form_contacts1.tpl');
            if( !$this->_error_no && $this->_status) {
                //$text .= '<b>Thanks for contacting us.</b> Your message has been delivered.';
                $BodyContent = new objTemplate();
                $text .= $BodyContent->Fetch('users/_contacts.tpl');
            }
            return $text;
        } //FlashFeedback

        public function Display() {
            echo $this->Render();
        } //Display

        public function ClassName() {
            return  __CLASS__;
        }//ClassName

    }//class objContactsDlg

//-------------------------------------------------------------------------------------------------------
?>